package com.itheima.exerciseTest.test40_49;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test41 {
    public static void main(String[] args) {
        // 男演员
        List<String> man = new ArrayList<>(List.of("成龙", "刘德华", "张学友", "郭富城", "黎明", "张凡"));
        // 女演员
        List<String> woman = new ArrayList<>(List.of("邓丽君", "林志颖", "蔡依林", "林玲", "曹云云", "林某人"));

        // 过滤男演员
        Stream<String> stream1 = man.stream().filter(s -> s.length() == 3).limit(3);

        // 过滤女演员
        Stream<String> stream2 = woman.stream().filter(s -> s.startsWith("林")).skip(1);

/*
        // 合并stream流
        Stream<String> concat = Stream.concat(stream1, stream2);

        // 遍历
        concat.forEach(s->{
            Actor a = new Actor();
            a.setName(s);
            System.out.println(a);
        });
*/

        List<String> collect = Stream.concat(stream1, stream2).collect(Collectors.toList());
        List<Actor> list = new ArrayList<>();
        for (String s : collect) {
            Actor a = new Actor();
            a.setName(s);
            list.add(a);
        }
        System.out.println(list);


    }
}

class Actor {
    private String name;

    public Actor() {
    }

    public Actor(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Actor{" +
                "name='" + name + '\'' +
                '}';
    }
}

